package cn.neusoft.service.impl;
import cn.neusoft.domain.Warehouse;
import cn.neusoft.mapper.WarehouseMapper;
import cn.neusoft.service.WarehouseService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WarehouseServiceImpl implements WarehouseService {


    @Autowired
    private WarehouseMapper warehouseMapper;

    @Autowired
    public WarehouseServiceImpl(WarehouseMapper warehouseMapper) {
        this.warehouseMapper = warehouseMapper;
    }

    @Override
    public void add(Warehouse warehouse) {
        warehouseMapper.add(warehouse);
    }

    @Override
    public void delete(Long warehouseId) {
        warehouseMapper.delete(warehouseId);
    }

    @Override
    public void update(Warehouse warehouse) {
        warehouseMapper.update(warehouse);
    }

    @Override
    public List<Warehouse> getAll() {
        return warehouseMapper.getAll();
    }

    @Override
    public Warehouse getById(Long warehouseId) {
        return warehouseMapper.getById(warehouseId);
    }

    @Override
    public List<Warehouse> getByWarehouseName(@Param("warehouseName") String warehouseName){
        return warehouseMapper.getByWarehouseName(warehouseName);
    }

    @Override
    public List<Warehouse> getWarehousesByPage(int page, int pageSize) {
        int start = (page - 1) * pageSize;
        return warehouseMapper.getWarehousesByPage(start, pageSize);
    }

    @Override
    public int getTotalCount() {
        return warehouseMapper.getTotalCount();
    }

    @Override
    public List<Warehouse> getWarehouseByLevel(Integer level) {
        return warehouseMapper.getWarehouseByLevel(level);
    }


}
